package application;



import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ContentDisplay;
import javafx.scene.image.ImageView;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
import javafx.scene.text.Text;
import javafx.stage.Stage;

public class ButtonDemo extends Application {

	Text text = new Text(50, 50, "JavaFx Programming");
	
	@Override
	public void start(Stage primaryStage) {
		Scene scene = new Scene(getPane());
		primaryStage.setScene(scene);
		primaryStage.setTitle("ButtonDemo");
		primaryStage.show();
		
	}
	
	protected BorderPane getPane() {
		HBox paneForButtons = new HBox(20);
		ImageView imageViewLeft = new ImageView("Left.png");
		imageViewLeft.setFitWidth(5.2);
		imageViewLeft.setFitHeight(5.9);
		ImageView imageViewRight = new ImageView("Right.png");
		imageViewRight.setFitWidth(5.2);
		imageViewRight.setFitHeight(5.9);
		
		
		Button btLeft = new Button("Left", imageViewLeft);
		Button btRight = new Button("Right", imageViewRight);
		btRight.setContentDisplay(ContentDisplay.RIGHT);
		paneForButtons.getChildren().addAll(btLeft, btRight);
		paneForButtons.setAlignment(Pos.CENTER);
		paneForButtons.setStyle("-fx-border-color: green");
		
		
		BorderPane pane = new BorderPane();
		pane.setBottom(paneForButtons);
		
		Pane paneForText = new Pane();
		paneForText.getChildren().add(text);
		paneForText.setPadding(new Insets(30, 30, 30, 30));
		
		pane.setCenter(paneForText);
		
		btLeft.setOnAction(e -> text.setX(text.getX() - 10));
		btRight.setOnAction(e -> text.setX(text.getX() + 10));
		
		return pane;
		
	}
	

	
	
	
	public static void main(String[] args) {
		Application.launch(args);
	}
}
